package com.flying.learning.si.sik.reader;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
import org.springframework.kafka.listener.ContainerProperties;
import org.springframework.messaging.PollableChannel;

@Configuration
public class ConsumerChannelConfig {
//    @Value("${spring.kafka.topic}")
//    private String springIntegrationKafkaTopic;

    @Bean
    public PollableChannel consumerChannel() {
        return new QueueChannel();
    }

//    @Bean
//    public KafkaMessageDrivenChannelAdapter kafkaMessageDrivenChannelAdapter(ConsumerFactory factory) {
//        ContainerProperties containerProps = new ContainerProperties(springIntegrationKafkaTopic);
//        KafkaMessageDrivenChannelAdapter kafkaMessageDrivenChannelAdapter =
//                new KafkaMessageDrivenChannelAdapter(new ConcurrentMessageListenerContainer(factory, containerProps));
//        kafkaMessageDrivenChannelAdapter.setOutputChannel(consumerChannel());
//        return kafkaMessageDrivenChannelAdapter;
//    }
}
